#!./perl
#req_more_info.pl

# parse disc name from ServerName Environt Variable with this script

do './variables.pl';

##############################################################################
# url_decode: transforms the received string to its original value.
##############################################################################
sub url_decode
{

#       Decode a URL encoded string or array of strings
#               + -> space
#               %xx -> character xx


    foreach (@_) {
        tr/+/ /;
        s/%0a //g;
        s/\^//g;
        s/%(..)/pack("c",hex($1))/ge;
    }
    @_;
}

##############################################################################
# MAIN PART: Decode the parameters and calls the correct subfunctions
##############################################################################
# get args
$request = $ENV{'QUERY_STRING'};
@params = &url_decode(split(/[&=]/, $request));
%paramPairs = @params;
$size = ($paramPairs{"SIZE"} eq "" ? 30 : $paramPairs{"SIZE"});
$dest = $paramPairs{"DEST"};
$alpha = $paramPairs{"L"};

#while (@params) {
	#$ARGV=shift;
	#$orig = $ARGV; 
	#$name = $orig;
	#$name =~ s/-.*//g; 
	#$param = $orig; 
	#$param =~ s/.*-//g; 
	##place custome params here
	#if ($name eq "size") {$size = $param;}
	#if ($name eq "dest") {$dest = $param;}
	#if ($name eq "alpha") {$alpha = $param;}
#}

$~ = HTMLHEADER;
write STDOUT;

#foreach $en (sort keys(%ENV)) {
	#print "$en = $ENV{$en}<br>\n";
#}

print "<FRAME SCROLLING=\"no\" TARGET=\"_top\" NAME=\"menu\" NORESIZE MARGINHEIGHT=4 SRC=\"file:///tmp/httpd/.products/.categories/$dest.head.html\">\n";
print "<FRAME SCROLLING=\"yes\" NAME=\"content\" NORESIZE MARGINHEIGHT=4 SRC=\"file:///tmp/httpd/.products/.categories/$dest.html\#$alpha\">\n";

$~ = HTMLFOOTER;
write STDOUT;
##############################################################################
format HTMLHEADER =
Content-type: text/html



<html>
<head>
<title>@*
$disc_name
 @*
$disc_rest
</title>
</head>
<FRAMESET ROWS="@<,80">
$size
.
##############################################################################
format HTMLFOOTER =
        <BODY BACKGROUND="icons/bkgrnds/homebg.gif" body bgcolor=black text=#ffffff link=#dddddd alink=#ffff00 vlink=#bbbbbb>


        <FONT SIZE=-1>Copyright \0511995 <B><A


        </BODY>

        </NOFRAME>


        </FRAMESET>

    </HTML>
.
